<?
require_once("head.php");
##########################################
function voir() {
##########################################
echo'<table width="600" border="1" cellspacing="0" cellpadding="0" align="center" class="content">';
$root='./archive/';
naviger($root);
echo'</table>';
}
##########################################
function naviger($chemin) {
##########################################
global$root ;
$rep=opendir($chemin);
while ($file = readdir($rep)){
        if($file != '..' && $file !='.' && $file !=''){
                if (is_dir($chemin.$file)){
                        echo"<tr><td colspan='5'><img src='./images/extentions/folder.png' width='16' height='16' align='absbottom'>&nbsp;<font class='bcontent'>$file</font>";
                        naviger($chemin.$file."/");
                         echo"</td></tr>";
                }else{
                if(file_exists("./images/extentions/".substr($file,-3).".png"))$fichiers.="<tr><td  width='16'></td><td  width='20'><img src='./images/extentions/".substr($file,-3).".png' width='16' height='16' align='bottom'></td><td> <a href='$PHP_SELF?file=$chemin$file'><font class='content'>$file</a></td><td  align='right'>".ceil((filesize($chemin.$file))/1000)."Ko </td><td align='right'>".date("d/m/Y", filectime($chemin.$file))."</td></tr>";
                }
        }

}
echo $fichiers;
closedir($rep);
clearstatcache();
}
############################################
function telecharger($file)  {
############################################
$fp = fopen($file, "w");
while ($data = fread($putdata, 1024)) {
fwrite($fp, $data);
}
fclose($fp);
fclose($putdata);

$mimetype = array();
$mimetype["ai"] = "application/postscript";
$mimetype["aif"] = "audio/x-aiff";
$mimetype["aifc"] = "audio/x-aiff";
$mimetype["aiff"] = "audio/x-aiff";
$mimetype["asc"] = "text/plain";
$mimetype["au"] = "audio/basic";
$mimetype["avi"] = "video/x-msvideo";
$mimetype["bcpio"] = "application/x-bcpio";
$mimetype["bin"] = "application/octet-stream";
$mimetype["bmp"] = "image/bmp";
$mimetype["cdf"] = "application/x-netcdf";
$mimetype["class"] = "application/octet-stream";
$mimetype["cpio"] = "application/x-cpio";
$mimetype["cpt"] = "application/mac-compactpro";
$mimetype["csh"] = "application/x-csh";
$mimetype["css"] = "text/css";
$mimetype["dcr"] = "application/x-director";
$mimetype["dir"] = "application/x-director";
$mimetype["djv"] = "image/vnd.djvu";
$mimetype["djvu"] = "image/vnd.djvu";
$mimetype["dll"] = "application/octet-stream";
$mimetype["dms"] = "application/octet-stream";
$mimetype["doc"] = "application/msword";
$mimetype["dvi"] = "application/x-dvi";
$mimetype["dxr"] = "application/x-director";
$mimetype["eps"] = "application/postscript";
$mimetype["etx"] = "text/x-setext";
$mimetype["exe"] = "application/octet-stream";
$mimetype["ez"] = "application/andrew-inset";
$mimetype["gif"] = "image/gif";
$mimetype["gtar"] = "application/x-gtar";
$mimetype["hdf"] = "application/x-hdf";
$mimetype["hqx"] = "application/mac-binhex40";
$mimetype["htm"] = "text/html";
$mimetype["html"] = "text/html";
$mimetype["ice"] = "x-conference/x-cooltalk";
$mimetype["ief"] = "image/ief";
$mimetype["iges"] = "model/iges";
$mimetype["igs"] = "model/iges";
$mimetype["jpe"] = "image/jpeg";
$mimetype["jpeg"] = "image/jpeg";
$mimetype["jpg"] = "image/jpeg";
$mimetype["js"] = "application/x-javascript";
$mimetype["kar"] = "audio/midi";
$mimetype["latex"] = "application/x-latex";
$mimetype["lha"] = "application/octet-stream";
$mimetype["lzh"] = "application/octet-stream";
$mimetype["m3u"] = "audio/x-mpegurl";
$mimetype["man"] = "application/x-troff-man";
$mimetype["me"] = "application/x-troff-me";
$mimetype["mesh"] = "model/mesh";
$mimetype["mid"] = "audio/midi";
$mimetype["midi"] = "audio/midi";
$mimetype["mif"] = "application/vnd.mif";
$mimetype["mov"] = "video/quicktime";
$mimetype["movie"] = "video/x-sgi-movie";
$mimetype["mp2"] = "audio/mpeg";
$mimetype["mp3"] = "audio/mpeg";
$mimetype["mpe"] = "video/mpeg";
$mimetype["mpeg"] = "video/mpeg";
$mimetype["mpg"] = "video/mpeg";
$mimetype["mpga"] = "audio/mpeg";
$mimetype["ms"] = "application/x-troff-ms";
$mimetype["msh"] = "model/mesh";
$mimetype["mxu"] = "video/vnd.mpegurl";
$mimetype["nc"] = "application/x-netcdf";
$mimetype["oda"] = "application/oda";
$mimetype["pbm"] = "image/x-portable-bitmap";
$mimetype["pdb"] = "chemical/x-pdb";
$mimetype["pdf"] = "application/pdf";
$mimetype["pgm"] = "image/x-portable-graymap";
$mimetype["pgn"] = "application/x-chess-pgn";
$mimetype["png"] = "image/png";
$mimetype["pnm"] = "image/x-portable-anymap";
$mimetype["ppm"] = "image/x-portable-pixmap";
$mimetype["ppt"] = "application/vnd.ms-powerpoint";
$mimetype["ps"] = "application/postscript";
$mimetype["qt"] = "qideo/quicktime";
$mimetype["ra"] = "audio/x-realaudio";
$mimetype["ram"] = "audio/x-pn-realaudio";
$mimetype["ras"] = "image/x-cmu-raster";
$mimetype["rgb"] = "image/x-rgb";
$mimetype["rm"] = "audio/x-pn-realaudio";
$mimetype["roff"] = "application/x-troff";
$mimetype["rpm"] = "audio/x-pn-realaudio-plugin";
$mimetype["rtf"] = "text/rtf";
$mimetype["rtx"] = "text/richtext";
$mimetype["sgm"] = "text/sgml";
$mimetype["sgml"] = "text/sgml";
$mimetype["sh"] = "application/x-sh";
$mimetype["shar"] = "application/x-shar";
$mimetype["silo"] = "model/mesh";
$mimetype["sit"] = "application/x-stuffit";
$mimetype["skd"] = "application/x-koan";
$mimetype["skm"] = "application/x-koan";
$mimetype["skp"] = "application/x-koan";
$mimetype["skt"] = "application/x-koan";
$mimetype["smi"] = "application/smil";
$mimetype["smil"] = "application/smil";
$mimetype["snd"] = "audio/basic";
$mimetype["so"] = "application/octet-stream";
$mimetype["spl"] = "application/x-futuresplash";
$mimetype["src"] = "application/x-wais-source";
$mimetype["sv4cpio"] = "application/x-sv4cpio";
$mimetype["sv4crc"] = "application/x-sv4crc";
$mimetype["swf"] = "application/x-shockwave-flash";
$mimetype["t"] = "application/x-troff";
$mimetype["tar"] = "application/x-tar";
$mimetype["tcl"] = "application/x-tcl";
$mimetype["tex"] = "application/x-tex";
$mimetype["texi"] = "application/x-texinfo";
$mimetype["texinfo"] = "application/x-texinfo";
$mimetype["tif"] = "image/tiff";
$mimetype["tiff"] = "image/tiff";
$mimetype["tr"] = "application/x-troff";
$mimetype["tsv"] = "text/tab-separated-values";
$mimetype["txt"] = "text/plain";
$mimetype["ustar"] = "application/x-ustar";
$mimetype["vcd"] = "application/x-cdlink";
$mimetype["vrml"] = "model/vrml";
$mimetype["wav"] = "audio/x-wav";
$mimetype["wbmp"] = "image/vnd.wap.wbmp";
$mimetype["wbxml"] = "application/vnd.wap.wbxml";
$mimetype["wml"] = "text/vnd.wap.wml";
$mimetype["wmlc"] = "application/vnd.wap.wmlc";
$mimetype["wmls"] = "text/vnd.wap.wmlscript";
$mimetype["wmlsc"] = "application/vnd.wap.wmlscriptc";
$mimetype["wrl"] = "model/vrml";
$mimetype["xbm"] = "image/x-xbitmap";
$mimetype["xht"] = "application/xhtml+xml";
$mimetype["xhtml"] = "application/xhtml+xml";
$mimetype["xls"] = "application/vnd.ms-excel";
$mimetype["xml"] = "text/xml";
$mimetype["xpm"] = "image/x-xpixmap";
$mimetype["xsl"] = "text/xml";
$mimetype["xwd"] = "image/x-xwindowdump";
$mimetype["xyz"] = "chemical/x-xyz";
$mimetype["zip"] = "application/zip";
$mimetype["gz"] = "application/gzip";
$mimetype["zip"] = "application/x-zip-compressed";

                      header('Pragma: public');
                      header('Expires: 0');
                      header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
                      header('Cache-Control: public');
                      header('Content-Description: File Transfer');
                      header('Content-Disposition: attachment; filename="'.$file.'"');
                      /*
                      if ((is_integer (strpos($this->user_agent, "msie"))) && (is_integer(strpos($this->user_agent, "win"))))
                      {
                      header("Content-Disposition: filename=".$this->filename.";");
                      }
                      else
                      {
                      header("Content-Disposition: attachment; filename=".$this->filename.";");
                      }
                      header("Content-Location: ".$this->path);
                      header("Content-Type: "."application/octet-stream");
                      header("Content-Length: ".$this->docfilesize );
                      header("Content-Encoding: application/octet-stream");
                      */
                      header('Content-Type: ' . $mimetype[substr($file,-3)]);
                      header('Content-Transfer-Encoding: binary');
                      echo base64_decode($data);

}
##########################################
switch ($op) {
##########################################
               case "telecharger":
               telecharger();
               break;

               default:
               voir();
               break;
}
##########################################
?>